from django.db.models import QuerySet
from django.test import TestCase
from App_SearchNovel.models import Books
from App_ReadNovel.models import *
from App_User_SigninAndRegister.models import *
from App_SearchNovel.Tools import *
from django.forms.models import model_to_dict
class testbook(TestCase):



    def testbooks(self):
        b1 = Books.objects.create(bookid="12",title="s",author="zsj",category="p",profile="asdf",nice=20)
        b2 = Books.objects.create(bookid="13",title="s",author="zsj",category="p",profile="asdf",nice=20)

        u1 = User.objects.create(userid=1,email="21142416566@qq.com",password="qweqwe")
        u2 = User.objects.create(userid=2,email="31142416566@qq.com",password="qweqwe")

        b1.iscollection.add(u1)
        b1.iscollection.add(u2)
        b2.iscollection.add(u1)
        b2.iscollection.add(u2)

        u = User.objects.get(userid=1)
        print("bookid" in dir(u.user_iscollection.all()))
        print(ParseBook(u.user_iscollection.all()))
        book = Books.objects.get(bookid="12")
        print(book.iscollection.get(userid=1).email)


